package com.urbane.dto.enums;

import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 订单状态枚举
 * 功能：
 *   - 统一所有服务使用的订单状态值
 *   - 避免出现 "pending"、"wait_pay"、"已支付" 等不一致写法
 *   - 与数据库字段、API 响应保持一致
 */
@Schema(description = "订单状态枚举")
public enum OrderStatus {

    PENDING_PAYMENT("待支付"),
    PAID("已支付"),
    SHIPPED("已发货"),
    DELIVERED("已签收"),
    COMPLETED("已完成"),
    CANCELLED("已取消");

    private final String description;

    OrderStatus(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    // 可添加静态方法：fromValue(String value)
    public static OrderStatus fromValue(String value) {
        for (OrderStatus status : values()) {
            if (status.name().equalsIgnoreCase(value)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知订单状态：" + value);
    }
}